﻿package mortal.game.view.task.drama.operations
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.game.manager.*;
    import mortal.game.view.task.drama.*;

    public class TaskDramaOpBlackScreen extends Object implements ITaskDramaStepCommand
    {
        private var _sp:GSprite;
        private static var _instance:TaskDramaOpBlackScreen;

        public function TaskDramaOpBlackScreen()
        {
            return;
        }// end function

        public function call(param1:TTaskDrama, param2:Function = null) : void
        {
            var onTime:Function;
            var data:* = param1;
            var callback:* = param2;
            onTime = function () : void
            {
                if (callback != null)
                {
                    callback.apply();
                }
                return;
            }// end function
            ;
            LayerManager.highestLayer.addChildAt(this.sp, 0);
            var time:Number;
            if (TaskDramaOperator.ationTime > 0)
            {
                time = TaskDramaOperator.ationTime;
            }
            setTimeout(onTime, time * 1000);
            return;
        }// end function

        public function cancel(param1:TTaskDrama, param2:Function = null) : void
        {
            if (this.sp.parent != null)
            {
                this.sp.parent.removeChild(this.sp);
            }
            if (param2 != null)
            {
                param2.apply();
            }
            return;
        }// end function

        public function dispose() : void
        {
            if (this._sp != null)
            {
                this._sp.dispose(true);
                this._sp = null;
            }
            return;
        }// end function

        private function get sp() : GSprite
        {
            if (this._sp == null)
            {
                this._sp = UICompomentPool.getUICompoment(GSprite);
                DisplayUtil.drawFullScreenMask(this._sp, 0, 1);
                this._sp.mouseChildren = false;
                this._sp.mouseEnabled = false;
            }
            return this._sp;
        }// end function

        public static function get instance() : TaskDramaOpBlackScreen
        {
            if (_instance == null)
            {
                _instance = new TaskDramaOpBlackScreen;
            }
            return _instance;
        }// end function

    }
}
